/********************************************************************************
 *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
 *                                                                              *
 *              This software is distributed under the terms of the             *
 *              GNU Lesser General Public Licence (LGPL) version 3,             *
 *                  copied verbatim in the file "LICENSE"                       *
 ********************************************************************************/

// -------------------------------------------------------------------------
// -----                    EtfMagnet  file                               -----
// -----                Created 26/03/14  by M. Al-Turany              -----
// -------------------------------------------------------------------------

#include "EtfMagnet.h"

#include "TGeoManager.h"
#include "FairRun.h"                    // for FairRun
#include "FairRuntimeDb.h"              // for FairRuntimeDb
#include "FairGeoMagnet.h"              // for FairGeoMagnet
#include "FairGeoNode.h"                // for FairGeoNode
#include "FairGeoPassivePar.h"          // for FairGeoPassivePar
#include "FairGeoVolume.h"              // for FairGeoVolume

#include <iosfwd>                       // for ostream
#include "TList.h"                      // for TListIter, TList (ptr only)
#include "TObjArray.h"                  // for TObjArray
#include "TString.h"                    // for TString
#include "TGeoBBox.h"
#include "TGeoCompositeShape.h"
#include "TGeoTube.h"
#include "TGeoMaterial.h"
#include "TGeoElement.h"
#include "TGeoMedium.h"
#include <stddef.h>                     // for NULL
#include <iostream>                     // for operator<<, basic_ostream, etc



EtfMagnet::~EtfMagnet()
{
}
EtfMagnet::EtfMagnet()
  : FairModule("EtfMagnet", "")
{
}

EtfMagnet::EtfMagnet(const char* name, const char* Title)
  : FairModule(name ,Title)
{
}

EtfMagnet::EtfMagnet(const EtfMagnet& right)
  : FairModule(right)
{
}

void EtfMagnet::ConstructGeometry()
{
	TString fileName=GetGeometryFileName();
	if (fileName.EndsWith(".geo")) {
		LOG(info)<<"Constructing geometry from ASCII file "<<fileName;
		ConstructASCIIGeometry();
	} else if (fileName.EndsWith(".root")) {
		LOG(info)<<"Constructing geometry from ROOT file "<<fileName;
		ConstructRootGeometry();
	} else {
		LOG(fatal) << "Geometry format not supported.";
	}


 /*  
    TGeoVolume *top=gGeoManager->GetTopVolume();
    
    // define some materials
    TGeoMaterial *matFe     = new TGeoMaterial("Fe", 55.84, 26, 7.9);

    // define some media
    TGeoMedium *Fe     = new TGeoMedium("Fe", 5, matFe);
    

    // magnet yoke
    TGeoBBox *magyoke1 = new TGeoBBox("magyoke1", 80, 50, 50);
    TGeoBBox *magyoke2 = new TGeoBBox("magyoke2", 40, 14, 51);
    
    TGeoCompositeShape *magyokec = new TGeoCompositeShape("magyokec", "magyoke1-magyoke2");
    TGeoVolume *magyoke = new TGeoVolume("magyoke", magyokec, Fe);
    magyoke->SetLineColor(kBlue);
    //magyoke->SetTransparency(50);
    top->AddNode(magyoke, 1, new TGeoTranslation(0, 0, 0));
*/
}
/*
void EtfMagnet::ConstructASCIIGeometry()
{
	FairGeoMagnet* MGeo=new FairGeoMagnet();

	FairModule::ConstructASCIIGeometry<FairGeoMagnet, FairGeoPassivePar>(MGeo, "FairGeoPassivePar");
}
*/


FairModule* EtfMagnet::CloneModule() const
{
  return new EtfMagnet(*this);
}

ClassImp(EtfMagnet)














